from cmath import *

j= complex(0,1)
mu = 4.0e-7*pi
ep = 8.854e-12

def pol(a,b=None):
    if type(a)==type(list()):
        return a[0]*exp(complex(0,1)*a[1]*pi/180)
    return a*exp(complex(0,1)*b*pi/180)

def arg(a):
    return ((log(a/abs(a))/complex(0,1)).real)*180/pi

def aa(a):
    return [abs(a), arg(a)]

def abcd(s11,s12,s21,s22,z0=50):
    return (1+s11)*z0/(1-s11),(1+s11)*z0/(-s21),(1+s22)*z0/(1-s22),(1+s22)*z0/(-s12)

def rlm(a,b,c,d,z0=50):
    return a*(b*d+c*50)/(b*d-a*c),c*(b*d+a*z0)/(b*d-a*c),b*c*(a+z0)/(a*c-b*d)

